package jbl.action;

import jbl.pageModel.DaLog;
import jbl.service.DaLogServiceI;
import jbl.util.Json;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ModelDriven;

/**
 * @author jblcxg
 * 
 * 档案申请调阅日志记录 和档案调阅处理类
 *
 */
@Namespace("/")
@Action(value="daLogAction")
public class DaLogAction extends BaseAction  implements ModelDriven<DaLog>{
	private DaLog daLog = new DaLog();
	private DaLogServiceI daLogService;
	
	@Autowired
	public void setDaLogService(DaLogServiceI daLogService) {
		this.daLogService = daLogService;
	}
	@Override
	public DaLog getModel() {
		return daLog;
	}
	
	/**
	 * 获取树形结构grid
	 */
	public void treegrid(){
		writeJson(daLogService.treegrid(daLog));
	}
	/**
	 * 获取dataGrid
	 */
	public void dataGrid(){
		writeJson(daLogService.dataGrid(daLog));
	}
	/**
	 * 申请调阅方法
	 */
	
	public void add(){
		Json j = null;
		try {
			j=daLogService.add(daLog);
		} catch (Exception e) {
			j = new Json();
			e.printStackTrace();
			j.setMsg("申请失败");
		}
		writeJson(j);
	}
	/**
	 * 处理申请调阅方法
	 */
	public void edit(){
		Json j = null;
		try {
			j = daLogService.edit(daLog);
		} catch (Exception e) {
			j = new Json();
			e.printStackTrace();
			j.setMsg("处理失败");
		}
		writeJson(j);
	}
	/**
	 * 处理申请请求
	 */
	public void fashEdit(){
		Json j = null;
		try {
			j = daLogService.fashEdit(daLog);
		} catch (Exception e) {
			j = new Json();
			e.printStackTrace();
			j.setMsg("处理失败");
		}
		writeJson(j);
	}
}
